from time import sleep
from unittest import TestCase
from selenium import webdriver

from po_study.po.GoodsListPage import GoodsListPage
from po_study.po.LoginPage import LoginPage


class TestEshopGoodList(TestCase):

    def test_search_by_key(self):    #测试 通过搜索框搜索关键字
        driver = webdriver.Chrome()
        login = LoginPage(driver)
        login.open('http://192.168.20.244/ecshop/admin/privilege.php?act=login')
        login.input_username()
        login.input_password()
        login.click_login_button()
        sleep(5)

        goods=GoodsListPage(driver)
        goods.into_menu_frame()
        goods.click_good_list()
        goods.out_frame()
        goods.into_main_frame()
        goods.input_search_text()
        goods.click_search_button()
        sleep(8)

    def test_select_by_text(self):   #测试通过下拉列表进行搜索
        driver = webdriver.Chrome()
        login = LoginPage(driver)
        login.open('http://192.168.20.244/ecshop/admin/privilege.php?act=login')
        login.input_username()
        login.input_password()
        login.click_login_button()
        sleep(5)

        goods = GoodsListPage(driver)
        goods.into_menu_frame()
        goods.click_good_list()
        goods.out_frame()
        goods.into_main_frame()
        sleep(2)
        goods.select_by_type()
        goods.click_search_button()
        sleep(8)

    # def add_goods(self):

